//package com.sdhs.paas.authclient.service;
//
//import java.util.List;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.core.ParameterizedTypeReference;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpMethod;
//import org.springframework.http.ResponseEntity;
//import org.springframework.stereotype.Service;
//import org.springframework.web.bind.annotation.RequestParam;
//
//import com.sdhs.paas.sdk.core.PaasBaseRequest;
//import com.sdhs.paas.sdk.core.PaasBaseResponse;
//import com.sdhs.paas.sdk.core.web.client.PaasRestTemplate;
//
//import dto.ClientDTO;
//
//@Service
//public class AuthService {
//	
//	@Autowired
//	PaasRestTemplate paasRestTemplate;
//	
//	public List<String> getAllowedClient(@RequestParam("serviceId") String serviceId,
//			@RequestParam("secret") String secret) {
//		ClientDTO clientDTO = new ClientDTO();
//		clientDTO.setServiceId(serviceId);
//		clientDTO.setSecret(secret);
//		ResponseEntity<PaasBaseResponse<ClientDTO>> result = paasRestTemplate.exchange(
//				"http://authserver/client/myClient", HttpMethod.POST,
//				new HttpEntity<>(new PaasBaseRequest<>(clientDTO)),
//				new ParameterizedTypeReference<PaasBaseResponse<ClientDTO>>() {
//				});
//		List<String> clientList = result.getBody().getBody().getAllowClientList();
//		return clientList;
//	}
//
//	public String getAccessToken(@RequestParam("clientId") String clientId,
//			@RequestParam("secret") String secret) {
//		ClientDTO clientDTO = new ClientDTO();
//		clientDTO.setClientId(clientId);
//		clientDTO.setSecret(secret);
//		ResponseEntity<PaasBaseResponse<ClientDTO>> result = paasRestTemplate.exchange(
//				"http://authserver/client/token", HttpMethod.POST,
//				new HttpEntity<>(new PaasBaseRequest<>(clientDTO)),
//				new ParameterizedTypeReference<PaasBaseResponse<ClientDTO>>() {
//				});
//		String token = result.getBody().getBody().getToken();
//		return token;
//	}
//
//	public byte[] getServicePublicKey(@RequestParam("clientId") String clientId,
//			@RequestParam("secret") String secret) {
//		ClientDTO clientDTO = new ClientDTO();
//		clientDTO.setClientId(clientId);
//		clientDTO.setSecret(secret);
//		ResponseEntity<PaasBaseResponse<ClientDTO>> result = paasRestTemplate.exchange(
//				"http://authserver/client/servicePubKey", HttpMethod.POST,
//				new HttpEntity<>(new PaasBaseRequest<>(clientDTO)),
//				new ParameterizedTypeReference<PaasBaseResponse<ClientDTO>>() {
//				});
//		byte[] key = result.getBody().getBody().getKey();
//		return key;
//	}
//
//	public byte[] getUserPublicKey(@RequestParam("clientId") String clientId,
//			@RequestParam("secret") String secret) {
//		ClientDTO clientDTO = new ClientDTO();
//		clientDTO.setClientId(clientId);
//		clientDTO.setSecret(secret);
//		ResponseEntity<PaasBaseResponse<ClientDTO>> result = paasRestTemplate.exchange(
//				"http://authserver/client/userPubKey", HttpMethod.POST,
//				new HttpEntity<>(new PaasBaseRequest<>(clientDTO)),
//				new ParameterizedTypeReference<PaasBaseResponse<ClientDTO>>() {
//				});
//		byte[] key = result.getBody().getBody().getKey();
//		return key;
//	}
//
//}
